<template>
	<view class="container">
		<template v-if="noticeObj">
			<view v-if="type==0">
			<!-- 	<text class="fw">【{{getMemberType(noticeObj.messageType)}}】</text> -->
				{{noticeObj.faqContent}}
			</view>
			<view v-else>{{noticeObj.faqContent}}</view>
		</template>
		<tui-modal></tui-modal>
		<loading></loading>
	</view>
</template>

<script>
	export default {
		
		data() {
			return {
				type:0,//0表示我的消息
				id:'',
				version:'',
				noticeObj:null,
				resultFlag:true,//后台返回是否成功
			};
		},
		onLoad(options){
			// #ifdef H5
			   this.$wechat.noShare();
			// #endif
			this.type=options.type;
			this.id=options.id;
			this.version=options.version;
			if(this.type==0){
				this.getMemberNotice();
			}else{
				this.getSysNotice();
			}
		},
		methods:{
			// getMemberType(type){
			// 	return ['普通消息','瘦身达人','产品体验','活动促销','新闻','积分'][type - 1]
			// },
			getMemberNotice(){
				const params = {
					version: this.version,
				};
				this.$http.memberNoticeInfo(this.id,params).then((res) => {
					if(res.status === 0) {
						this.noticeObj=res.data;
					}else{
						this.resultFlag=false
					}
				})
			},
			getSysNotice(){
				const params = {
					version: this.version,
				};
				this.$http.sysNoticeInfo(this.id,params).then((res) => {
					if(res.status === 0) {
						this.noticeObj=res.data;
					}else{
						this.resultFlag=false
					}
				})
			},
		},
		onUnload() {
			if(this.type==0&&this.resultFlag){//后台返回成功，已阅读
				this.$util.prePage().changeStatus();
			}
			// if(this.type==0){
			// 	this.$util.prePage().getMemberNoticeList({num:1,size:10});
			// }else if(this.type==1){
			// 	this.$util.prePage().getSysNoticeList({num:1,size:10});
			// }
			
		}
	}
</script>

<style lang="scss">
	.container {
		padding-bottom: env(safe-area-inset-bottom);
		overflow: hidden;
		width: 100%;
		min-height: 100vh;
		box-sizing: border-box;
		background-color: #fff;
		border-top:2rpx solid $borderColor;
		padding:30rpx;
		font-size: 30rpx;
		.fw{
			font-weight: bold;
		}
	}
	
</style>
